<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>省补资金请款录入</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/Top.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
	<link rel="stylesheet" type="text/css" href="/jxcsxm/js/autocomplete/jquery.autocomplete.css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/uploader/swfobject.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/uploader/jquery.uploadify.v2.1.4.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/widget/newlhgdialog/lhgcore.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/widget/newlhgdialog/lhgdialog.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/YWLib.js"></script>
 	<script type="text/javascript" src="${pageContext.request.contextPath}/js/autocomplete/jquery.autocomplete.js" ></script>
	
	<style type="text/css">
		<!--
		a:link {text-decoration: none;}
		a:visited {text-decoration: none;}
		a:hover {text-decoration: none;}
		a:active {text-decoration: none;}
		#bbtable {border-collapse:collapse;}
		#bbtable thead tr td {text-align:center;font-size:1em;font-weight:bold;border:1px solid #FFEBCD;padding:3px 7px 2px 7px;}
		#bbtable tbody tr td {text-align:center;font-size:1em;border:1px solid #FFEBCD;padding:3px 7px 2px 7px;}
		-->
	</style>
	<script type="text/javascript">
	$(function(){
		autoCompleteXmmc();
		loadBmbm3('xmnf','项目年份');
		getTbXmList();
	});
		
	function autoCompleteXmmc(){
		$("#xmmc").autocomplete("/jxcsxm/tjbb/autoxmmc.do", {
			multiple : false,
			minChars :1,
			multipleSeparator : ' ',
			mustMatch: true,
	  		cacheLength : 0,
	  		delay : 0,
	  		max : 150,
	  		extraParams : {
	  				"xmjbxx.xmmc":function() {
	  				var d = $("#xmmc").val();
	  				return d;
	  			}
	  		},
	  		dataType : 'json',// 返回类型
	  		// 对返回的json对象进行解析函数，函数返回一个数组
	  		parse : function(data) {
	  			var aa = [];
	  			aa = $.map(eval(data), function(row) {
	  					return {
	  						data : row,
	  						value : row.xmmc.replace(/(\s*$)/g,""),
	  						result : row.xmmc.replace(/(\s*$)/g,"")
	  					};
	  				});
	  			return aa;
	  		},formatItem : function(row, i, max) {
	  			return row.xmmc.replace(/(\s*$)/g,"");
	  		}
	  	}).result(function(e, item) {
	  		
		});
	}
	
	
	
	function getTbXmList(){
		/* var xzqhdm=$("#xzqh").combotree("getValues");
		var xzqhstr="";
		if(xzqhdm.length==0){
			xzqhstr= $.cookie("dist2");
		}else if(xzqhdm.length==1){
			if(xzqhdm[0].substr(xzqhdm[0].length-2,xzqhdm[0].length)=="00") xzqhdm[0]=xzqhdm[0].substr(0,xzqhdm[0].length-2);
			if(xzqhdm[0].substr(xzqhdm[0].length-2,xzqhdm[0].length)=="00") xzqhdm[0]=xzqhdm[0].substr(0,xzqhdm[0].length-2);
			xzqhstr=xzqhdm[0] ;
		}else{
			xzqhstr= xzqhdm.join(',');
		} */
		var params={
				'xmjbxx.xmmc':$("#xmmc").val(),
				'xmjbxx.xmnf':getValuesById("xmnf")
			};
		
		
		$('#grid').datagrid({    
		    url:'/jxcsxm/tjbb/selectsbzjList.do',
		    striped:true,
		    pagination:true,
		    rownumbers:true,
		    pageNumber:1,
		    pageSize:10,
		    checkOnSelect:true,
		    height:$(window).height()-135,
		    width:$('#righttop').width()-22,
		    queryParams: params,
		    columns:[[	 
		    	//{field:'allSel',title:'全选',width:60,align:'center',rowspan:1,checkbox:'true'}, 
		    	{field:'cz',title:'操作',width:350,align:'center',
			    	formatter: function(value,row,index){
			    		// console.log(row);
			    		var result='<a style="text-decoration:none;color:#3399CC;" href=javascript:xmInfo("'+index+'")>详情</a>&nbsp;&nbsp;';
						 result+='<a style="text-decoration:none;color:#3399CC;" href=javascript:editXm("'+index+'")>编辑</a>&nbsp;&nbsp;';
	                     result+='<a style="text-decoration:none;color:#3399CC;" href=javascript:delXm("'+row.id+'")>删除</a>&nbsp;&nbsp;';
	                     result+='<a style="text-decoration:none;color:#3399CC;" onclick="approvalDocuments('+index+')" href="#">文件</a>&nbsp;&nbsp;';
	                     result+='<a style="text-decoration:none;color:#3399CC;" onclick="exportqklrmbdc('+index+')" href="#">请款模板下载</a>&nbsp;&nbsp;';
	                     result+='<a style="text-decoration:none;color:#3399CC;" onclick="importqklr('+index+')" href="#">请款导入</a>';
						return result;
			    	}
			    },
			    {field:'xmmc',title:'项目名称',width:300,align : 'center'},
			    {field:'twh',title:'厅文号',width:150,align : 'center'},
			    {field:'jwh',title:'局文号',width:150,align : 'center'},
				{field:'jhje',title:'计划金额(万元)',width:100,align : 'center'},
			    {field:'xmdj',title:'项目等级',width:70,align : 'center'},
			    {field:'xmnf',title:'项目年份',width:70,align : 'center'},
			    {field:'bz',title:'备注',width:200,align : 'center'}
		    ]],
		    view: detailview,
			detailFormatter:function(index,row){  
		        return '<div style="padding:2px"><table id="table_lx' + row.id + '"></table></div>';   
		    },
		    onExpandRow: function(index,row){
		    	//var parentindex=index;
		    	$('#table_lx'+row.id).datagrid({
		    		url:'/jxcsxm/tjbb/queryysqlist.do',
		    		queryParams: {
		    			'xmjbxx.jhid':row.id,
		    			'xmjbxx.page':1,
		    			'xmjbxx.rows':100
		    		},
	    			columns:[[
//	    				{field:'allSel',title:'全选',width:60,align:'center',rowspan:1,checkbox:'true'}, 
	    			    {field:'cz',title:'操作',width:100,align:'center',
	    			    	formatter: function(value,row,index){
	    			    		//console.log(row);
	    			    		var result='<a style="text-decoration:none;color:#3399CC;" href=javascript:delsqmx("'+row.id+'")>删除</a>&nbsp;&nbsp;';
	    			    		result+='<a style="text-decoration:none;color:#3399CC;" href=javascript:editsqXm("'+row.id+'","'+row.bcje+'","'+row.zhjhje+'","'+row.sqrq+'","'+row.bz+'","'+row.xmlx+'")>编辑</a>&nbsp;&nbsp;';
								return result;
	    			    	}
	    			    },
	    			    {field:'zhjhje',title:'用户计划金额(万元)',width:150,align:'center'},
	    			    {field:'sqrq',title:'申请日期',width:150,align:'center'},
	    				{field:'bcje',title:'申请金额(万元)',width:100,align:'center'},
	    				{field:'hm',title:'户名',width:175,align:'center'},
	    				{field:'khh',title:'开户行',width:225,align:'center'},
	    				{field:'zh',title:'账号',width:200,align:'center'},
	    				{field:'xmlx',title:'项目类型',width:100,align:'center'},
	    				{field:'bz',title:'备注',width:200,align:'center'}
	    			    
	    			]],onLoadSuccess:function(){
	    				$('#grid').datagrid('fixDetailRowHeight',index);    
	    	            setTimeout(function () {
	    	            	  var tr=$('#table_lx'+row.xmbm).closest('tr');
	    		                id = tr.prev().attr('id'); //此子表格父行所在行的id
	    	                    id = id.replace(/-2-(\d+)$/, '-1-$1'); //detailview没有展开的前部分的id是有规则的
	    	                    //通过下面的这2个示例你应该不难看出改变的是什么
	    	                    //datagrid-row-r1-1-0
	    	                    //datagrid-row-r1-2-0
	    	                    $('#' + id).next().css('height', tr.height());//设置没展开的前部分的高度，由于启用了计时器，会闪一下
	    	            }, 0);
	    				
	    			}
		    	});
		    },
		    onLoadSuccess: function(){
	            var dg = $(this);
	            var rows=dg.datagrid("getRows");
		    	for (var i=0;i<rows.length;i++){
		    		if(rows[i].xmsl==1){
		    			//这块是如果没有的话就隐藏加号
		    			dg.datagrid('getExpander', i).hide();
		    		}
		    	}
		    	
			}

		});
		
	}
	function editsqXm(id,bcje,zhjhje,sqrq,bz,xmlx){
		//alert(id);
		//alert(YMLib.Var.data);
		YMLib.Var.data={};
		YMLib.Var.data.id=id;
		YMLib.Var.data.bcje=bcje;
		YMLib.Var.data.zhjhje=zhjhje;
		YMLib.Var.data.sqrq=sqrq;
		YMLib.Var.data.bz=bz;
		YMLib.Var.data.xmlx=xmlx;
		YMLib.UI.createWindow('mywin',"编辑","sbzjqklrsqXm_bj.jsp",'mywin','600','300');	
	}
	function delsqmx(id){
		if(confirm("您确认删除吗？"))
		$.ajax({
			url:'/jxcsxm/tjbb/delsqmx.do',
			data:"xmjbxx.id="+id,
			type:'post',
			dataType:'json',
			success:function(msg){
				alert("删除成功")
				$("#ysqlb").datagrid('reload');
			}
				
		})
		
	}

	function exportqklrmbdc(index){
		loadjzt();
		YMLib.Var.data=$('#grid').datagrid('getRows')[index];
		var params={'xmjbxx.mbtitle':'请款','xmjbxx.xmmc':YMLib.Var.data.xmmc
		};
		postDownLoadFile({
			url:'/jxcsxm/tjbb/exportqklrmbdc.do',
			data:params,
			method:'post'
		});

		setTimeout('disLoadjzt()',4000);
	}

	function importqklr(index){
		// YMLib.Var.data=$('#grid').datagrid('getRows')[index];
		var url="/jxcsxm/tjbb/importqklr.do?gydwdm="+$.cookie("unit");
		var flag='sbzjdr';
		openWindow("导入数据","/jxcsxm/page/sjdr.jsp?url="+url+"&flag="+flag,500,300);
		//importSj(url,flag);;
	}

	function exportjhlrgsd(){
		loadjzt();
		postDownLoadFile({
			url:'/jxcsxm/tjbb/exportjhlrgsd.do',
			//data:params,
			method:'post'
		});

		setTimeout('disLoadjzt()',4000);
	}

	function exportjhlrncgl(){
		loadjzt();
		postDownLoadFile({
			url:'/jxcsxm/tjbb/exportjhlrncgl.do',
			//data:params,
			method:'post'
		});

		setTimeout('disLoadjzt()',4000);
	}

	function delXm(id){
		if(confirm("您确认删除吗？"))
		$.ajax({
			url:'/jxcsxm/tjbb/delsq.do',
			data:"xmjbxx.id="+id,
			type:'post',
			dataType:'json',
			success:function(msg){
				alert("删除成功")
				$("#grid").datagrid('reload');
			}
				
		})
		
	}
	
	
	function xmInfo(index){
		YMLib.Var.data=$('#grid').datagrid('getRows')[index];
		YMLib.UI.createWindow('mywin',"详情","sbzjqklr_info.jsp",'mywin','1100','550');	
	}
	
	function editXm(index){
		YMLib.Var.data=$('#grid').datagrid('getRows')[index];
		YMLib.UI.createWindow('mywin',"编辑","sbzjqklr_bj.jsp",'mywin','1100','550');	
	}
	
	function addsbzj(){
		YMLib.UI.createWindow('mywin',"添加","sbzjqklr_tj.jsp",'mywin','1100','550');	
	}


	function approvalDocuments(index){
		var data=$("#grid").datagrid('getRows')[index];
		obj=data;
		YMLib.UI.createWindow('lxxx','省补资金请款文件','sbzjqkwj.jsp','lxxx',800,240);
	}
	
	</script>
	<style type="text/css">
TD {
font-size: 12px;
}
a{
text-decoration:none;
}
.abgc_td td{padding-right:5px;}
</style>
</head>
<body>
	<div style="text-align: left; font-size: 12px; margin: 0px;">
		<table width="99.9%" border="0" style="margin-top: 1px; margin-left: 1px;" cellspacing="0" cellpadding="0">
			<tr>
					<div id="righttop">
						<div id="p_top">当前位置>&nbsp;统计报表>&nbsp;省补计划资金统计>&nbsp;省补资金请款录入</div>
					</div>
        	</tr>
        	<tr>
        		<td align="left" style="padding-left: 10px; padding-right: 10px;">
        			<fieldset style="width:99.9%; text-align: left; vertical-align: middle;margin: 8px 0px 0px 0px;">
        				<legend style="padding: 0 0 0 0; font-weight: bold; color: Gray; font-size: 12px;">
        					<font style="color: #0866A0; font-weight: bold"></font>
        				</legend>
        				<div>
        					<table style="margin:7px; vertical-align:middle;" cellspacing="0" class="abgc_td" >
					
								<tr height="28">
									
									<td align="right">项目名称：</td>
        							<td><input type='text' id="xmmc" style="width: 220px;" /></td>
									<td align="right">项目年份：</td>
        							<td><select id="xmnf" style="width: 80px;"></select></td>
								</tr>
        					
        					<tr height="28">
                            	<td colspan="8">
                            		<a id='mybuttion1' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:getTbXmList()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">查询</a>
									<a id='mybuttion2' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:addsbzj()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion2')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion2')"  class="button button-tiny button-rounded button-raised button-primary">添加</a>
									<a id='mybuttion3' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:exportjhlrgsd()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion3')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion3')"  class="button button-tiny button-rounded button-raised button-primary">国省道模板下载</a>
									<a id='mybuttion4' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:exportjhlrncgl()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion4')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion4')"  class="button button-tiny button-rounded button-raised button-primary">农村公路模板下载</a>

<!--                             		<a id='mybuttion3' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:importBb()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion3')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion3')"  class="button button-tiny button-rounded button-raised button-primary">导入报表</a> -->
<!--                             		<a id='mybuttion2' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:exportBb()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion2')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion2')"  class="button button-tiny button-rounded button-raised button-primary">导出报表</a> -->
								</td>
                            </tr>
							</table>
        				</div>
        			</fieldset>
        		</td>
        	</tr>
            <tr>
            	<td style="padding-top: 10px;padding-left:10px;padding-right:10px;">
                	<table id="grid"></table>
				</td>
			</tr>
		</table>
	</div>
</body>
</html>
